<template>
  <div>
    <div align="center">
    <el-card style="width: 1500px" align="center">
      <el-row>

        <el-col :span="7">
        <el-input placeholder="请输入查询内容" v-model="quaryInfo.quary" clearable @clear="getCustomMessage"></el-input>
        </el-col>
        <el-col  :span="1">
          <el-button type="primary" icon="el-icon-search" @click="getCustomMessage">搜索</el-button>
        </el-col>
      </el-row>
    <el-row>
      <el-col :span="4"></el-col>
      <el-col>
    <el-table :data="customlist" border stripe style="width: 100%" align="center" height="700">
      <el-table-column prop="customID" v-if="show=false"></el-table-column>
    <el-table-column prop="date" label="日期" width="200%"></el-table-column>
    <el-table-column prop="customName" label="姓名" width="100%"></el-table-column>
    <el-table-column prop="province" label="省份" width="100%"></el-table-column>
    <el-table-column prop="city" label="市区" width="100%"></el-table-column>
    <el-table-column prop="address" label="地址" width="300%"></el-table-column>
    <el-table-column prop="postNum" label="邮编" width="100%"></el-table-column>
    <el-table-column  label="操作" width="500">
      <template slot-scope="scope">
        <el-button @click="handleClick(scope.row)" type="primary" icon="el-icon-view">查看</el-button>
        <el-button type="primary" icon="el-icon-edit"
                   @click="editdialogVisible(scope.row.customID,scope.row.date,scope.row.customName,scope.row.province,scope.row.city,scope.row.address,scope.row.postNum)">
          编辑</el-button>
        <el-button type="primary" icon="el-icon-upload">上传审核资料</el-button>
        <el-button type="danger" icon="el-icon-delete">删除</el-button>
      </template>
    </el-table-column>
  </el-table>
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="quaryInfo.PageNum"
        :page-sizes="[10, 20, 30, 40]"
        :page-size="quaryInfo.PageSize"
        layout=" sizes, prev, pager, next, total, jumper"
        :total="total">
      </el-pagination>
        <el-dialog
          title="编辑客户基础信息"
          :visible.sync="EditdialogVisible"
          width="30%" @close="EditdialogVisible = false">
          <el-form ref="EditFromRef" :model="EditFrom" label-width="70px">
            <el-form-item label="日期：" >
                <el-date-picker type="date" placeholder="选择日期"  value-format="yyyy-MM-dd" format="yyyy-MM-dd" style="width: 100%;" v-model="EditFrom.date"></el-date-picker>
            </el-form-item>
            <el-form-item label="姓名：">
              <el-input v-model="EditFrom.CustomName"></el-input>
            </el-form-item>
            <el-form-item label="省份：">
              <el-input v-model="EditFrom.Province"></el-input>
            </el-form-item>
            <el-form-item label="市区：">
              <el-input v-model="EditFrom.City"></el-input>
            </el-form-item>
            <el-form-item label="地址：">
              <el-input v-model="EditFrom.Address"></el-input>
            </el-form-item>
            <el-form-item label="邮编：">
              <el-input v-model="EditFrom.PostNum"></el-input>
            </el-form-item>
          </el-form>
          <span slot="footer" class="dialog-footer">
           <el-button type="primary" @click="confirmUpdate">确认修改</el-button>
            <el-button @click="EditdialogVisible = false">取 消</el-button>
          </span>
        </el-dialog>
      </el-col>
      <el-col :span="4"></el-col>
    </el-row>
    </el-card>
    </div>
  </div>
</template>

<script>
  export default {
    methods: {
      handleClick(row) {
      }
    },

    data() {
      return {
        quaryInfo:{
          quary:'',
          PageNum:1,
          PageSize:10
        },
        customlist:[],
        total:0,
        EditdialogVisible : false,
        EditFrom:{
          customID:'',
          date:'',
          CustomName:'',
          Province:'',
          City:'',
          Address:'',
          PostNum:''
        }
      }
    },
    created(){
      this.getCustomMessage()
    },
    methods:{
      async getCustomMessage(){
      const {data:res}=await this.$http.get('neishen/readNeishen',{params:this.quaryInfo})
        this.customlist = res.Custom
        this.total=res.total
        this.PageSize=res.PageSize
        this.PageNum=res.PageNum
      },
      handleSizeChange(NewSize){
        this.quaryInfo.PageSize = NewSize
        this.getCustomMessage()

      },
      handleCurrentChange(NewPage){
        this.quaryInfo.PageNum = NewPage
        this.getCustomMessage()
      },
      async editdialogVisible(id,date,name,pro,city,addr,ponu){
        this.EditFrom.customID=id
        this.EditFrom.date=date
        this.EditFrom.CustomName=name
        this.EditFrom.Province=pro
        this.EditFrom.City=city
        this.EditFrom.Address=addr
        this.EditFrom.PostNum=ponu
        this.EditdialogVisible = true
      },
      confirmUpdate(){
        
        this.$http.get('neishen/updateByID',{params:this.EditFrom})
        this.$message.success('修改成功!');
        this.EditdialogVisible = false
      }

    }
  }
</script>
